package utilities;

import object.Scroll;
import java.awt.Graphics;

/**
 *
 * Class managing the scrolling background objects
 */

public class ScrollManager
{
    private String scrollImages[]={"back","front"};
    private double moveFactors[]={0.2,0.5};

    private Scroll[] scrolls;
    private Scroll gameOverScreen;

    private int numberOfScrolls;
    private int moveSize;

    private boolean gameOver=false;

    public ScrollManager(int width,int height,int tileMoveSize,ImageLoader imLoader)
    {
        moveSize=tileMoveSize;
        numberOfScrolls=scrollImages.length;
        scrolls=new Scroll[numberOfScrolls];

        for (int i=0;i<numberOfScrolls;i++)
            scrolls[i]=new Scroll(imLoader.getImage(scrollImages[i]),width,height,(int)(moveFactors[i]*moveSize));
        gameOverScreen=new Scroll(imLoader.getImage("gameOver"),width,height,0);;

    }


    public void moveRight()
    {
        for (int i=0;i<numberOfScrolls;i++)
            scrolls[i].moveRight();
    }

    public void moveLeft()
    {
        for (int i=0;i<numberOfScrolls;i++)
            scrolls[i].moveLeft();
    }

    public void stayStill()
    {
        for (int i=0;i<numberOfScrolls;i++)
            scrolls[i].stayStill();
    }


    public void update()
    {
        for (int i=0;i<numberOfScrolls;i++)
            scrolls[i].update();
    }

    public void display(Graphics g)
    {
        for (int i=0;i<numberOfScrolls;i++)
            scrolls[i].display(g);
        if (gameOver)
            gameOverScreen.display(g);
    }

    public void setGameOver()
    {
        gameOver=true;
    }
}
